﻿using System.Collections;
using System.Collections.Generic;
using EzFrameWork;
using UnityEngine;
using UnityEngine.Events;
namespace EzFrameWork
{
    public class EzAudioManager : Singleton<EzAudioManager>
    {
        private EzAudioComponent audioComponent;
        
        public EzAudioManager()
        {
            if (audioComponent!=null)
            {
                ToolUnity.Destroy(audioComponent.gameObject);
            }
            GameObject obj = new GameObject("AudioManager");
            audioComponent = obj.AddComponent<EzAudioComponent>();
        }
         
        public void PlayBGM(string path, bool isLoop = true)
        {
            audioComponent.PlayBGM(path, isLoop);
        }

        /// <summary>
        /// 停止所有BGM
        /// </summary>
        public void StopAllBgm(string path)
        {
            audioComponent.StopAllBgm(path);
        }

        /// <summary>
        /// 停止所有BGM
        /// </summary>
        public void StopBgm(string path)
        {
            audioComponent.StopBgm(path);
        }

        /// <summary>
        /// 根据路径加载音频
        /// </summary>
        /// <param name="path"></param>
        /// <param name="audioType"></param>
        public void PlayAudio(string type, string path)
        {
            audioComponent.PlayAudio(type, path);
        }


        public void PlayOneShotAudio(string Name, string path)
        {
            audioComponent.PlayOneShotAudio(Name, path);
        }

        //创建一个AudioSource物体
        public void CreateAudioSourceItem(string type, string path, Vector3 position, UnityAction<AudioSource> action)
        {
            audioComponent.CreateAudioSourceItem(type, path, position, action);
        }
        //创建一个AudioSource物体
        public void CreateAudioSourceItem(string type, string path, Transform parent, UnityAction<AudioSource> action)
        {
            audioComponent.CreateAudioSourceItem(type, path, parent, action);
        }
        public void CreateAudioSourceItem(string type, string path, UnityAction<AudioSource> action)
        {
            audioComponent.CreateAudioSourceItem(type, path, action);
        }

    }
}
//Audio 的管理者
